package com.wjy.task;

import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.text.SimpleDateFormat;
import java.util.Date;

@Component
public class TimeTask {

    private static final SimpleDateFormat FORMAT = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

    @Scheduled(fixedRate = 10 * 1000)
    public void getCurrentTime() {

        Date date = new Date();

        String time = FORMAT.format(date);

        System.out.println(time);

    }

}
